/** 
 * Copyright 2010 Erlacher Felix, Estgfaeller Wolfgang, Ferula Patrick
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package at.socialconference.app;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import at.socialconference.app.model.APlace;

public class PlaceActivity extends Activity {
	private TextView tvTitle;
	private TextView tvDescription;
	private Button btnMap;
	private APlace place;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.placeview);

		tvTitle = (TextView) findViewById(R.id.plv_title);
		tvDescription = (TextView) findViewById(R.id.plv_description);
		btnMap = (Button) findViewById(R.id.plv_map);

		Bundle b = getIntent().getExtras();
		place = (APlace)b.getParcelable("place");

		tvTitle.setText(place.getName()!=null?place.getName():"--");
		tvDescription.setText(place.getDescription()!=null?place.getDescription():"--");

		double lat = place.getLatitude();
		double lon = place.getLongitude();
		if(lat!=0 && lon!=0){
			btnMap.setOnClickListener(new OnClickListener() {	
				@Override
				public void onClick(View v) {
					Intent intent = new Intent().setClass(PlaceActivity.this, MapsActivity.class); 

					Bundle bun = new Bundle();
					bun.putDouble("lat", place.getLatitude()); 
					bun.putDouble("lon", place.getLongitude()); 
					intent.putExtras(bun);
					startActivity(intent);
				}
			}
			);
		}else{
			btnMap.setVisibility(View.GONE);
		}

	}
}
